#define _CRT_SECURE_NO_WARNINGS 1


#include <stdio.h>
#include <stdlib.h>
#include <string.h>

typedef struct TreeNode
{
    char val;
    struct TreeNode* left;
    struct TreeNode* right;
}TNode;

struct TreeNode* Create(char x)
{
    TNode* node = (TNode*)malloc(sizeof(TNode));
    if (node == NULL)
    {
        perror("malloc fail");
        exit(-1);
    }


    node->val = x;
    node->left = NULL;
    node->right = NULL;

    return node;
}

TNode* CreateTree(const char* a, int* pi)
{

    if (a[(*pi)] == '#')
    {
        (*pi)++;
        return NULL;
    }

    TNode* root = Create(a[(*pi)++]);

    root->left = CreateTree(a, pi);
    root->right = CreateTree(a, pi);

    return root;
}

void InOrder(struct TreeNode* root)
{
    if (root == NULL)
    {
        return;
    }
    InOrder(root->left);
    printf("%c ", root->val);
    InOrder(root->right);
}


//int main()
//{
//    int i = 0;
//    char a[101];
//    char ch = 0;
//    while(scanf("%s",a) != EOF)
//    {
//        getchar();
//        struct TreeNode* root = CreateTree(a, &i);
//        InOrder(root);
//        printf("\n");
//    }
//
//    return 0;
//}